package collection.print;

import java.util.*;

public class PrintingContainers {
    static Collection fill(Collection<String> collection) {
        collection.add("rat");
        collection.add("cat");
        collection.add("dog");
        collection.add("dog");
        return collection;
    }
    static Map fill(Map<String, String> map) {
        map.put("rat", "Fuzzy");
        map.put("cat", "Rags");
        map.put("dog", "Bosco");
        map.put("dog", "Spot");
        return map;
    }

    public static void main(String[] args) {
        System.out.println(fill(new ArrayList<String>()));//按顺序存储元素
        System.out.println(fill(new LinkedList<String>()));//包含的操作多余ArrayList
        System.out.println(fill(new HashSet<String>()));//元素无序、唯一，最快的获取元素的存储方式
        System.out.println(fill(new TreeSet<String>()));//按照比较结果的升序存储元素
        System.out.println(fill(new LinkedHashSet<String>()));//按照被添加的顺序保存对象
        System.out.println(fill(new HashMap<String, String>()));//最开的查找技术
        System.out.println(fill(new TreeMap<String, String>()));//比较结果的升序存储键
        System.out.println(fill(new LinkedHashMap<String, String>()));//按照插入顺序保存键，还保留了HashMap的查询速度

        Iterator<String> iterator = fill(new ArrayList<String>()).iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            System.out.println(s);
        }

    }
}
